/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package web.enity;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 *
 * @author 10592
 */
public class CartItem {
    private Book book;
    private int number;
    private double price;

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public double getPrice() {
        return this.price = book.getPrice() * number;
    }


    void add(int i) {
//        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        number+=i;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 19 * hash + Objects.hashCode(this.book);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj!=null) {
              CartItem cartItem=(CartItem)obj;
              if (cartItem.getBook()!=null) {
                  return cartItem.getBook().getBid()==this.getBook().getBid();
             
                }else
                    return false;

        }else
            return false;
        
       
    }
    
}
